home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Hardware / Mac OS USB DDK / Mac OS USB DDK 1.4.1 / Examples / KeyboardModule / KeyboardModule.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-25  |  3.2 KB  |  118 lines  |  [TEXT/CWIE]

  1. /*
  2.     File:        KeyboardModule.h
  3.  
  4.     Contains:    Header file for Keyboard Module
  5.  
  6.     Version:    xxx put version here xxx
  7.  
  8.     Copyright:    © 1997-1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10. */
  11. #ifndef __KeyboardModuleH__
  12. #define __KeyboardModuleH__
  13.  
  14. #include <Types.h>
  15. #include <Devices.h>
  16. #include <DriverServices.h>
  17. #include <Processes.h>
  18. #include <USB.h>
  19.  
  20. #if UNIVERSAL_INTERFACES_VERSION <= 0x0330
  21.     // the following were not defined in UI&L 3.3 nor in USB.h 1.4 and will generate compiler 
  22.     // errors 
  23. #define kUSBVersion14    0x01400000    
  24. #define kUSBPortDisabled    -6969
  25. #endif
  26.  
  27.  
  28. #define    kKeyboardModuleName    "\pUSBHIDKeyboardModule"
  29.  
  30. void     PostUSBKeyToMac(UInt16 rawUSBkey);
  31. void    PostADBKeyToMac(UInt16 virtualKeycode, UInt8 state);
  32.  
  33. void    USBDemoKeyIn(UInt32 refcon, void * theData);
  34. void    InitUSBKeyboard(void);
  35. void     KBDHIDNotification(UInt32 devicetype, UInt8 NewHIDData[], UInt8 OldHIDData[]);
  36.  
  37. Boolean    SetBit(UInt8 *bitmapArray, UInt16 index, Boolean value);
  38.  
  39. static     OSStatus    KeyboardModuleInitialize(USBDeviceRef device, USBDeviceDescriptorPtr pDesc, UInt32 busPowerAvailable);
  40. static     OSStatus    KeyboardInterfaceInitialize(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterface, USBDeviceDescriptorPtr pDesc, USBDeviceRef device);
  41. static     OSStatus    KeyboardModuleFinalize(USBDeviceRef theDeviceRef, USBDeviceDescriptorPtr pDesc);
  42.  
  43. void     InitParamBlock(USBReference theInterfaceRef, USBPB * paramblock);
  44. void    KeyboardInitiateTransaction(USBPB *pb);
  45. void    KeyboardCompletionProc(USBPB *pb);
  46. void    InterfaceEntry(UInt32 interfacenum, USBInterfaceDescriptorPtr pInterfaceDescriptor, USBDeviceDescriptorPtr pDeviceDescriptor, USBReference theInterfaceRef);
  47.  
  48. OSErr     FindHIDInterfaceByNumber(LogicalAddress pConfigDesc, UInt32 ReqInterface, USBInterfaceDescriptorPtr * hInterfaceDesc);
  49. void     NotifyRegisteredHIDUser(UInt32 devicetype, UInt8 hidReport[]);
  50.  
  51. #define kKeyboardRetryCount        3
  52. #define kKeyboardModifierBits    8
  53. #define kKeyboardReportKeys        6
  54. #define    kKeyboardOffsetToKeys    2
  55. #define kKeyboardReportSize        8
  56.  
  57. enum driverstages
  58. {
  59.     kUndefined = 0,
  60.     kSetKeyboardLEDs,
  61.     kConfigureInterface,
  62.     kSetProtocol,
  63.     kSetIdleRequest,
  64.     kSetRemoteWakeup,
  65.     kFindPipe,
  66.     kReadInterruptPipe,
  67.     kClearFeature,
  68.     kGetPortStatus,
  69.     kResetMouse,
  70.     kResetMouseDelay,
  71.     kPortStatusDelay,
  72.     kStageMask =            0x00ff,
  73.     kReturnFromDriver =     0x1000,
  74.     kRetryTransaction =     0x2000,
  75.     kSyncTransaction =         0x4000,
  76.     kCompletionPending =     0x8000
  77. };
  78.  
  79. typedef struct
  80. {
  81.     USBPB                             pb;
  82.     void (*handler)(USBPB             *pb);
  83.  
  84.     USBReference                    interfaceRef;
  85.     USBPipeRef                        pipeRef;
  86.     
  87.     USBDeviceDescriptor             deviceDescriptor;
  88.     USBInterfaceDescriptor            interfaceDescriptor;
  89.  
  90.     USBInterfaceDescriptorPtr        pInterfaceDescriptor;
  91.     USBEndPointDescriptorPtr        pEndpointDescriptor;
  92.     
  93.     UInt32                            hidDeviceType;
  94.     UInt8                            hidReport[8];
  95.     UInt8                            oldHIDReport[8];
  96.     UInt8                            padding[8];
  97.     
  98.     Boolean                            sendRawReportFlag;
  99.     Boolean                            hidEmulationInit;
  100.     Boolean                            keyboardReady;
  101.     Boolean                            intPipeAborted;
  102.     Boolean                            driverRemovalPending;
  103.     
  104.     HIDInterruptProcPtr             pSHIMInterruptRoutine;
  105.     HIDInterruptProcPtr             pSavedInterruptRoutine;
  106.     
  107.     UInt32                            interruptRefcon;
  108.     
  109.     SInt32                             retryCount;
  110.     SInt32                            delayLevel;
  111.     SInt32                            transDepth;
  112.     
  113.     SInt32                            usbVersion;
  114.     UInt32                            previousState;
  115.     
  116. } usbKeyboardPBStruct;
  117.  
  118. #endif //__KeyboardModuleH__